package oop.core.skill;

import oop.core.map.Location;

public class SkillObjectWithLocation implements Cloneable{
	private SkillObject skillObject;
	private Location location;
	
	public SkillObjectWithLocation(SkillObject skillObject, Location location){
		this.skillObject = skillObject;
		this.location = location;
	}

	public SkillObject getSkillObject() {
		return skillObject;
	}

	public void setSkillObject(SkillObject skillObject) {
		this.skillObject = skillObject;
	}

	public Location getLocation() {
		return location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}
	
	public SkillObjectWithLocation clone(){
		try {
			SkillObjectWithLocation cloned = (SkillObjectWithLocation)super.clone();
			cloned.skillObject = this.skillObject.clone();
			cloned.location = this.location.clone();
			return cloned;
		} catch (CloneNotSupportedException e){
			e.printStackTrace();
			return null;
		}
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((location == null) ? 0 : location.hashCode());
		result = prime * result
				+ ((skillObject == null) ? 0 : skillObject.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SkillObjectWithLocation other = (SkillObjectWithLocation) obj;
		if (location == null) {
			if (other.location != null)
				return false;
		} else if (!location.equals(other.location))
			return false;
		if (skillObject == null) {
			if (other.skillObject != null)
				return false;
		} else if (!skillObject.equals(other.skillObject))
			return false;
		return true;
	}
	
}
